#include<bits/stdc++.h>
using namespace std;
int read(){
	int a=0;
	bool flag=true;
	char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')
		flag=!flag;
		ch=getchar();
	}
	while(isdigit(ch)){
		a=a*10+ch-'0';
		ch=getchar();
	}
	if(flag)return a;
	return -a;
	
}
void write(int a){
	if(a==0||a==-0){
		putchar('0');
		return;
	}
	if(a<=0){
		a=-a;
		putchar('-');
	}
	short i=0,s[20];
	char ch;
	while(a>0){
		s[++i]=a%10;
		a/=10;
	}
	while(i>0){
		ch=s[i]+'0';
		putchar(ch);
		i--;
	}
	return;
}
int n,a[2000000];
long long l1=1,sum=0;
bool b[2000000];
long long jisuan(){
	sum=0;
	for(int i=2;i<=n;i++){
		int j=i-1;
		for(;j>=1;j--){
			if(b[i]==b[j])break;
		}
		if(j==0)continue;
		if(a[i]==a[j])sum+=a[i];
	}
	return sum;
}
long long dfs(int h){
	if(h==n){
		int x,y;
		b[h]=true;
		x=jisuan();
		b[h]=false;
		y=jisuan();
		return max(x,y);
	}
	int x,y;
	b[h]=true;
	x=dfs(h+1);
	b[h]=false;
	y=dfs(h+1);
	return max(x,y);
}
int main(){
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	for(int T=read();T>=1;T--){
		n=read();
		for(int i=1;i<=n;i++)a[i]=read();
		cout<<dfs(1)<<endl;
	}
	
	return 0;
}
